﻿/* @(#)GSOrderSubmitSdConfirmAction.java   
 *
 * Project: GS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *    Tuthmos    2008-09-22     新增
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import system.LoginContext;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.business.GSOrderDeptInfoProcessor;
import com.hitrust.gs.business.GSOrderProcessor;
import com.hitrust.gs.business.GSUniteGwProcessor;
import com.hitrust.gs.form.GSOrderSubmitForNonFlatForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

/**
 * 执行手工订单明细送货确认
 */
public class GSOrderSubmitSdConfirmAction extends GSBaseAction {


    public String execute(GSBaseForm aForm) throws Exception {
        GSOrderSubmitForNonFlatForm tForm = (GSOrderSubmitForNonFlatForm)aForm;
        
        //取得订单明细编号
        String[] tOrderDetailId = tForm.orderDetailIds;
        
        //取得当前操作员信息
        LoginContext context = (LoginContext)tForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        if(tOrderDetailId != null && tOrderDetailId.length > 0){
	        GSOrderProcessor tOrderProc = new GSOrderProcessor();
	        
	        //提交非交易平台商户订单明细
	        boolean tFlag = tOrderProc.submitOrderDetailForNonFlatsd(tOrderDetailId,context.getLoginUserId());
	        if(!tFlag){
	            tForm.getRequest().setAttribute("message","手工订单明细提交失败");
	        }else{
	            tForm.getRequest().setAttribute("message","共" + tOrderDetailId.length + "笔订单明细修改为已确认成功");
	        }
        }else{
        	tForm.getRequest().setAttribute("action","A150401.do");
        	GSLogWriter.error(this,GSException.E00003_MSG);
        	throw new GSException(GSException.E00003,GSException.E00003_MSG);
        }
        //取得当前操作员可查询的订货单位和送货地址
        GSUniteGwProcessor unitePro = new GSUniteGwProcessor();
        ArrayList wareList = unitePro.getWareHouseLevelName(context.getLoginWarehouseCode(),context.getLoginWarehouseCode());
        aForm.getRequest().setAttribute("orderdept", wareList);
        //取得产品分类
        GSManufactureProcessor tManufProc = new GSManufactureProcessor();
        tManufProc.getManufactureOfLevel(aForm);
        tForm.getRequest().setAttribute("requery","true");
        
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
